package com.happy3w.ssp.schoolmatehome.component.image;

import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

import java.util.List;

@RequiredArgsConstructor
@Component
public class TypePrinterManager {
    private final List<TypePrinter<?>> printers;
    public TypePrinter<Object> findPrinter(Object item) {
        for (TypePrinter<?> printer : printers) {
            if (printer.isSupport(item)) {
                return (TypePrinter<Object>) printer;
            }
        }
        throw new IllegalArgumentException("Unsupported type:" + item.getClass().getName());
    }
}
